﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Extension;
using System;
[AddComponentMenu("UI/SubjectiveLayout")]
public class SubjectiveLayout : MonoBehaviour
{
    [SerializeField]
    ControlSubject m_subject = new ControlSubject(false);
    public ControlSubject subject { get { return m_subject; } }

    void Start()
    {
        if (subject.hasContent)  AssignPosition();
    }

    private void AssignPosition()
    {
        Vector3 pos = transform.localPosition;
        pos.x = (float)subject.value;
        pos.y = 0;
        transform.localPosition = pos;
    }

    void LateUpdate()
    {
        if (subject.hasUpdate)   AssignPosition();
    }
}
